-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transparent compiler #1240
Transparent compiler #1240
Conversation
4f6ccba
to
0242c14
Compare
@@ -680,6 +730,7 @@ | |||
let bind (mapping: 'a -> CancellationToken -> asyncaval<'b>) (value: asyncaval<'a>) = | |||
let mutable cache: option<_> = None | |||
let mutable innerCache: option<_> = None | |||
let mutable outerDataCache: option<_> = None |
Check notice
Code scanning / Ionide.Analyzers.Cli
Detect if generic type should be in the postfix position. Note
42c2357
to
bcaabe9
Compare
e0dbfbf
to
8226064
Compare
@@ -18,10 +18,13 @@ | |||
module LanguageVersionShim = | |||
val defaultLanguageVersion: Lazy<LanguageVersionShim> | |||
|
|||
|
|||
val fromOtherOptions: options: seq<string> -> LanguageVersionShim |
Check notice
Code scanning / Ionide.Analyzers.Cli
Detect if generic type should be in the postfix position. Note
|
||
member ScriptTypecheckRequirementsChanged: IEvent<unit> | ||
|
||
member RemoveFileFromCache: file: string<LocalPath> -> unit | ||
|
||
member ClearCache: snap: seq<FSharpProjectSnapshot> -> unit |
Check notice
Code scanning / Ionide.Analyzers.Cli
Detect if generic type should be in the postfix position. Note
3a5d660
to
b0c079d
Compare
381198b
to
acbfe87
Compare
real.ContinueWith(fun (task: Task<_>) -> | ||
match task.Status with | ||
| TaskStatus.RanToCompletion -> tcs.TrySetResult task.Result |> ignore<bool> | ||
| TaskStatus.Canceled -> | ||
tcs.TrySetCanceled(TaskCanceledException(task).CancellationToken) | ||
|> ignore<bool> | ||
| TaskStatus.Faulted -> tcs.TrySetException(task.Exception.InnerExceptions) |> ignore<bool> | ||
|
||
| _ -> ()) | ||
|> ignore<Task> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed back to ContinueWith
style as getting stack traces weren't working properly. Wish I had a good idea how to make a test for that.
match! inMemorySourceFiles |> AMap.tryFind sourcePath with | ||
| Some volatileFile -> return! volatileFile |> AVal.map createFSharpFileSnapshotInMemory | ||
| None -> return! createFSharpFileSnapshotOnDisk sourceTextFactory sourcePath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes to source files, either in memory or on disk will cause snapshots to be recreated.
>> Log.addContextDestructured "projectFileName" p.ProjectFileName | ||
) | ||
|
||
snapshot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finding an already created snapshot keeps memory use down.
let! projectFileName = projectFileName | ||
and! projectId = projectId | ||
and! sourceFiles = sourceFiles | ||
and! referencePaths = referencePaths | ||
and! otherOptions = otherOptions | ||
and! referencedProjects = referencedProjects | ||
and! isIncompleteTypeCheckEnvironment = isIncompleteTypeCheckEnvironment | ||
and! useScriptResolutionRules = useScriptResolutionRules | ||
and! loadTime = loadTime | ||
and! unresolvedReferences = unresolvedReferences | ||
and! originalLoadReferences = originalLoadReferences |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, any changes to any of these could recreate a snapshot. In practice only a few of these change
referencePath.Substring(3) // remove "-r:" | ||
|> createReferenceOnDisk) | ||
|
||
let referencedProjects = mapReferences p |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where it creates/finds referenced snapshots, and when those change it will recreate the current snapshot.
|
||
member DisableInMemoryProjectReferences: bool with get, set | ||
|
||
static member GetDependingProjects: | ||
file: string<LocalPath> -> | ||
options: seq<string * FSharpProjectOptions> -> | ||
(FSharpProjectOptions * FSharpProjectOptions list) option | ||
snapshots: seq<string * CompilerProjectOption> -> |
Check notice
Code scanning / Ionide.Analyzers.Cli
Detect if generic type should be in the postfix position. Note
options: seq<string * FSharpProjectOptions> -> | ||
(FSharpProjectOptions * FSharpProjectOptions list) option | ||
snapshots: seq<string * CompilerProjectOption> -> | ||
option<CompilerProjectOption * list<CompilerProjectOption>> |
Check notice
Code scanning / Ionide.Analyzers.Cli
Detect if generic type should be in the postfix position. Note
options: seq<string * FSharpProjectOptions> -> | ||
(FSharpProjectOptions * FSharpProjectOptions list) option | ||
snapshots: seq<string * CompilerProjectOption> -> | ||
option<CompilerProjectOption * list<CompilerProjectOption>> |
Check notice
Code scanning / Ionide.Analyzers.Cli
Detect if generic type should be in the postfix position. Note
|
||
member GetProjectOptionsFromScript: | ||
file: string<LocalPath> * source: ISourceText * tfm: FSIRefs.TFM -> | ||
Async<FSharpProjectOptions * FSharpDiagnostic list> | ||
Async<FSharpProjectOptions * list<FSharp.Compiler.Diagnostics.FSharpDiagnostic>> |
Check notice
Code scanning / Ionide.Analyzers.Cli
Detect if generic type should be in the postfix position. Note
file: string<LocalPath> * snapshot: FSharpProjectSnapshot -> ParseAndCheckResults option | ||
|
||
member TryGetRecentCheckResultsForFile: | ||
file: string<LocalPath> * options: FSharpProjectOptions * source: ISourceText -> option<ParseAndCheckResults> |
Check notice
Code scanning / Ionide.Analyzers.Cli
Detect if generic type should be in the postfix position. Note
Async<FSharpSymbolUse array> | ||
|
||
member FindReferencesForSymbolInFile: | ||
file: string * project: FSharpProjectOptions * symbol: FSharpSymbol -> Async<seq<range>> | ||
file: string<LocalPath> * project: FSharpProjectSnapshot * symbol: FSharpSymbol -> Async<seq<range>> |
Check notice
Code scanning / Ionide.Analyzers.Cli
Detect if generic type should be in the postfix position. Note
file: string<LocalPath> * project: FSharpProjectSnapshot * symbol: FSharpSymbol -> Async<seq<range>> | ||
|
||
member FindReferencesForSymbolInFile: | ||
file: string<LocalPath> * project: FSharpProjectOptions * symbol: FSharpSymbol -> Async<seq<range>> |
Check notice
Code scanning / Ionide.Analyzers.Cli
Detect if generic type should be in the postfix position. Note
|
||
member __.DisableInMemoryProjectReferences | ||
with get () = disableInMemoryProjectReferences | ||
and set (value) = disableInMemoryProjectReferences <- value | ||
|
||
static member GetDependingProjects (file: string<LocalPath>) (options: seq<string * FSharpProjectOptions>) = | ||
static member GetDependingProjects (file: string<LocalPath>) (snapshots: seq<string * CompilerProjectOption>) = |
Check notice
Code scanning / Ionide.Analyzers.Cli
Detect if generic type should be in the postfix position. Note
@@ -9,16 +9,15 @@ | |||
[<RequireQualifiedAccess; NoComparison>] | |||
type SymbolDeclarationLocation = | |||
| CurrentDocument | |||
| Projects of FSharpProjectOptions list * isLocalForProject: bool | |||
| Projects of CompilerProjectOption list * isLocalForProject: bool |
Check notice
Code scanning / Ionide.Analyzers.Cli
Verifies each field in a union case is named. Note
43076cc
to
ae52948
Compare
Ok I think this is finally ready. This can now be turned on/off so we can merge safely without fear of being able to use the old stuff since transparent compiler may still have issues that we have no control of directly. |
8e6b98e
to
8696c11
Compare
Ok, I'd be a fan of merging this into the nightly branch and playing with it for a while. |
Unfortunately there isn't a way to add generic parameters via Ionide. (means that should get added at some point). I do have a PR available in Ionide to add it but you'll have to build a run a custom version of Ionide to access the setting.
Are you sure that actually works? I'm only using |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few notes and a couple questions as I was reading through this.
I'm surprised by how understandable this was, despite the large amount of changes. I think this says a lot about the comments you left and the places you unified previous logic.
let! ct = CancellableTask.getCancellationToken () | ||
let inner = mapping i ct | ||
return inner | ||
RefCountingTaskCreator(fun ct -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this the same throughout this file? moving from cancellableTask
to task
for better stack traces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I need to rundown why I was still getting weird stacktraces but I'll do that later.
/// <summary> | ||
/// An awaitable wrapper around a task whose result is disposable. The wrapper is not disposable, so this prevents usage errors like "use _lock = myAsync()" when the appropriate usage should be "use! _lock = myAsync())". | ||
/// </summary> | ||
[<Struct>] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beautiful type - thanks for this
@@ -418,7 +433,7 @@ type AdaptiveState(lspClient: FSharpLspClient, sourceTextFactory: ISourceTextFac | |||
|
|||
|
|||
let runAnalyzers (config: FSharpConfig) (parseAndCheck: ParseAndCheckResults) (volatileFile: VolatileFile) = | |||
async { | |||
asyncEx { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the direct use of async
be a code smell for us now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, though we can make additional PRs to hit all those places.
|
||
|
||
let compilers = | ||
match getEnvVarAsStr "USE_TRANSPARENT_COMPILER" with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TheAngryByrd, hmm, ok now I'm doubting whether that did work or not.
It might not have and I was seeing things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I hardcoded the useTransparentCompiler to true locally and I remain with my past statements: all goes well for me, ship it.
Co-authored-by: Chet Husk <[email protected]>
Co-authored-by: Chet Husk <[email protected]>
Adds support for Transparent Compiler in FSAC.